package com.hmsm.sys.service;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import com.hmsm.sys.bean.LocalUser;
import com.hmsm.sys.dto.UserDto;
import com.lzyyj.common.Page;

public interface IUserInfoService<T extends LocalUser, PK extends Serializable> extends Serializable {

	public T getCurrentUser();

	public T getNew() throws Exception;
	
	public T save(T userVo, T currentUser) throws Exception;

	public T save(T userVo, String propertyList, T currentUser) throws Exception;

	public T update(T userVo) throws Exception;

	public T update(T userVo, String propertyList) throws Exception;
	
	public void deleteById(int userId) throws Exception;

	public T get(T instance) throws Exception;

	public Page<T> manage(Page<T> page, T currentUser) throws Exception;

	/**
	 * 获取重名用户列表
	 * 
	 * @return
	 */
	public Map<String, List<T>> getRepLoginNameMap() throws Exception;

	/**
	 * 合并登录名账户
	 * 
	 * @param loginName
	 * @throws Exception
	 */
	public void mergeLoginName(String loginName) throws Exception;


	/**
	 * 为设置用户角色而获取用户相关信息
	 * 
	 * @param item
	 * @return
	 * @throws Exception
	 */
	public T getForSetRoles(T item) throws Exception;

	public List<T> findByProperty(String propertyName, Object value, String orderBy, String propertyList, long... firstAndMaxResults) throws Exception;

	public List<T> getAll();

	public T getById(Integer userId);

	public T getByUserName(String userName) throws Exception;

	public T login(String userName, String md5) throws Exception;

	public T login(String accountSource, String userName, String md5) throws Exception;

	public List<T> getAdmins();

	public String getUserLoginTime(Integer userId);

	public List<Integer> getUserIdsByDeptId(Integer deptId);

	public T getForModify(PK userId, T currentUser) throws Exception;

	public T getForModify(PK userId, Integer deptId, T currentUser) throws Exception;

	/**
	 * 加载用户部门
	 * @param userInfo
	 */
	public void loadUserDepart(T userInfo);

	/**
	 * 加载用户部门
	 * @param userInfo
	 * @param deptId	当前关注部门(优先)
	 * @param pattern
	 */
	public void loadUserDepart(T userInfo, Integer deptId, int pattern);

	public void loadUserRoles(T userInfo, T currentUser) throws Exception;

	public void updateUserRoles(T userInfo) throws Exception;
	
	public T getUserInfoByUserCode(Integer pkId, String userName);

	public void updatePassword(String password, T currentUser) throws Exception;
	
	public void resetPassword(Integer userId, T currentUser) throws Exception;
	
	public void bindingUserMLInfo(int pkId,int sn);
	
	public void jcBinding(int pkId);

	public List<UserDto> getUserInfoByDeptId(int deptId);

	public T getByDingId(String dingId);

	public T getByRelevanceUserName(String accountSource, String account);

	public T getByTelPhone(String telPhone);

	/**
	 * 查询重复登录名用户数
	 * @return
	 */
	public int getDupLoginNameCount();

	/**
	 * 查询是否有管理员权限
	 * @param currentUser
	 * @return
	 * @throws Exception 
	 */
	public boolean haveAdminRight(T currentUser) throws Exception;

	/**
	 * 获取部门成员
	 * @param deptInfo
	 * @return
	 */
	public List<T> getUsersByDeptId(Integer deptId);

}
